package model_response

import "go-admin/internal/model"

type ListJobResponse struct {
	CommonId
	IsBanned string `json:"isBanned"` // 是否禁用
	JobName  string `json:"jobName"`  // 岗位名称
	JobCode  string `json:"jobCode"`  // 岗位编码
	CommonCreatedOn
}

type ListJobKVResponse struct {
	CommonId
	JobName string `json:"jobName"` // 岗位名称
	JobCode string `json:"jobCode"` // 岗位编码
}

type JobDetailResponse struct {
	CommonId
	JobName  string `json:"jobName"`  // 岗位名称
	JobCode  string `json:"jobCode"`  // 岗位编码
	IsBanned string `json:"isBanned"` // 是否禁用
	Remark   string `json:"remark"`   // 备注
}

func ModelToListJobRes(models []*model.Job) []*ListJobResponse {
	var list []*ListJobResponse
	for _, m := range models {
		l := ListJobResponse{
			CommonId:        CommonId{m.Id},
			JobName:         m.JobName,
			JobCode:         m.JobCode,
			IsBanned:        m.IsBanned,
			CommonCreatedOn: CommonCreatedOn{CreatedOn: m.CreatedOn},
		}
		list = append(list, &l)
	}
	return list
}

func ModelToJobKVRes(models []*model.Job) []*ListJobKVResponse {
	var kvs []*ListJobKVResponse
	for _, m := range models {
		kv := &ListJobKVResponse{
			CommonId: CommonId{Id: m.Id},
			JobName:  m.JobName,
			JobCode:  m.JobCode,
		}
		kvs = append(kvs, kv)
	}
	return kvs
}

// 模型转详情结构体
func ModelToDetailJobRes(model *model.Job) *JobDetailResponse {
	dictItem := &JobDetailResponse{
		CommonId: CommonId{Id: model.Id},
		JobName:  model.JobName,
		JobCode:  model.JobCode,
		IsBanned: model.IsBanned,
		Remark:   model.Remark,
	}
	return dictItem
}
